package merisis.spindle;

import merisis.util.BitaSet;
import merisis.util.BitaSetIterator;
import merisis.util.LinearArrowArraySet;

public class Spindle {

	LinearArrowArraySet graph;

	MarkCellArrangement arrange;

	public Spindle(String uri) {

	}

	public long reach(long... points) {

		long newpoint = graph.reach(points);
		return newpoint;
	}

	public long[] product(long[] points) {

		/*
		 * The cell would be stale while emergence of points. snapshot for
		 * lock-free.
		 */
		long snapshot0 = arrange.snapshot();

		BitaSet noarranged = new BitaSet();
		Cell corecell = arrange.findCoreCell(points, noarranged);
		if (points.length == noarranged.cardinality()) {
			// no any arranged points

			BitaSet pts = new BitaSet();
			pts.setAscendingPoints(points);

			long distal;
			BitaSetIterator distalItr = pts.iteratorInversed();

			distal = distalItr.next();

			long proximal;
			BitaSet proximals = (BitaSet) noarranged.clone();
			BitaSetIterator proximalItr = proximals.iteratorInversed();
			while ((proximal = proximalItr.next()) != -1) {

				if (graph.proofed(proximal, distal))
					continue;

				proximalItr.unset();
			}

			while ((distal = distalItr.next()) != -1) {

			}
		}

		return null;
	}

}
